/**
 * 按需加载Vant组件库
 */

import {
  Toast,
  Dialog,
  Overlay,
  Area,
  Swipe,
  SwipeItem,
  ImagePreview,
  Calendar,
  Picker,
  DatetimePicker,
  Button,
  List,
  Cell,
  CellGroup,
  Field,
  Icon,
  Uploader,
  NoticeBar,
  ActionSheet,
  NavBar,
  Progress,
  Circle,
  Divider,
  Skeleton,
  Loading
} from 'vant'

import SingletonToast from './SingletonToast'

// 默认Toast允许多例模式
Toast.allowMultiple()

export default {
  install (Vue) {
    // 全局组件
    Vue
      .use(Dialog)
      .use(Overlay)
      .use(Area)
      .use(Swipe)
      .use(SwipeItem)
      .use(ImagePreview)
      .use(Calendar)
      .use(Picker)
      .use(DatetimePicker)
      .use(Button)
      .use(List)
      .use(Cell)
      .use(CellGroup)
      .use(Field)
      .use(Icon)
      .use(Uploader)
      .use(NoticeBar)
      .use(ActionSheet)
      .use(NavBar)
      .use(Progress)
      .use(Circle)
      .use(Divider)
      .use(Skeleton)
      .use(Loading)

    // Toast单例版
    Vue.prototype.$toast = SingletonToast
  }
}
